package org.jeecg.modules.zonglzp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.zonglzp.entity.CompanyEntity;
import org.jeecg.modules.zonglzp.entity.Customer;
import org.jeecg.modules.zonglzp.entity.User;
import org.jeecg.modules.zonglzp.entity.store;
import org.jeecg.modules.zonglzp.mapper.CompanyMapper;
import org.jeecg.modules.zonglzp.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyMapper mapper;

    /*
    通过用户token获取用户id
     */
    @Override
    public String getUseridbytoken(String token) {
        return mapper.getUseridbytoken(token);
    }


    //通过用户id查询公司信息
    @Override
    public CompanyEntity getCompanybyuserId(String userid) {
        return mapper.getCompanybyuserId(userid);
    }

    //通过公司id查询门店列表
    @Override
    public IPage<store> querystoreBycompanyId(String companyId, Page<store> page, String orgCode) {
        return mapper.querystoreBycompanyId(page, companyId,orgCode);
    }


    //通过公司id查询员工列表
    @Override
    public IPage<User> getyuangonglistBycompanyId(String companyId, Page<User> page) {
        return mapper.getyuangonglistBycompanyId(page, companyId);
    }


    //新增门店
    @Override
    public int addstore(store store) {
        store.setCreateTime(new Date());
        return mapper.addstore(store);
    }


    //新增客户
    @Override
    public int addcustomer(Customer customer) {
        customer.setCreateTime(new Date());
        return mapper.addcustomer(customer);
    }


    //新增员工
    @Override
    public int addstaff(User user) {
        return mapper.addstaff(user);
    }

    //通过token查询老的标识
    @Override
    public String getoldidentification(String token) {
        return mapper.getoldidentification(token);
    }

    @Override
    public int updateidentification(String identification, String token) {
        return mapper.updateidentification(identification, token);
    }


    @Override
    public int updatestore(store store) {
        return mapper.updatestore(store);
    }

    @Override
    public int updatestaff(User user) {
        return mapper.updatestaff(user);
    }

    @Override
    public User getcompanysetbytoken(String token) {
        return mapper.getcompanysetbytoken(token);
    }

    @Override
    public int updatecompanysetbytoken(User user) {
        return mapper.updatecompanysetbxytoken(user);
    }

    @Override
    public int deletestore(int storeid) {
        return mapper.deletestore(storeid);
    }


    //删除员工
    @Override
    public int deletestaff(int id) {
        return mapper.deletestaff(id);
    }

    //判断工号是否存在
    @Override
    public String queryworknamebyworkname(String workNumber) {
        return mapper.queryworknamebyworkname(workNumber);
    }


    //判断登录账号是否存在
    @Override
    public String queryusername(String userName) {
        return mapper.queryusername(userName);
    }


    //判断门店名字是否已经存在
    @Override
    public String querystoreName(String storeName) {
        return mapper.querystoreName(storeName);
    }


    //判断门店编号是否已经存在
    @Override
    public String querystoreCode(String storeCode) {
        return mapper.querystoreCode(storeCode);
    }

    //根据门店id查询门店
    @Override
    public store getstorebyid(int storeId) {
        return mapper.getstorebyid(storeId);
    }


    //根据人员id查询人员
    @Override
    public User getstaffbyid(int id) {
        return mapper.getstaffbyid(id);
    }


    //通过token查询公司id
    @Override
    public int queryCompanyId(String token) {
        return mapper.queryCompanyId(token);
    }


    //通过token查询公司的code
    @Override
    public String queryCompanyCode(String token) {
        return mapper.queryCompanyCode(token);
    }

    //通过公司id查询品牌标集合
    @Override
    public List<Map<String, Object>> getppbList(int companyId) {
        return mapper.getppbList(companyId);
    }


    //通过id删除品牌标志
    @Override
    public int deleteppb(int id) {
        return mapper.deleteppb(id);
    }

    @Override
    public int updateppb(int id, String ppbname) {
        return mapper.updateppb(id, ppbname);
    }

    //新增品牌标
    @Override
    public int addppb(String companyId, String ppbname) {
        return mapper.addppb(companyId, ppbname, new Date());
    }

    @Override
    public int getidbykehubianhao(String wenzi) {
        return mapper.getidbykehubianhao(wenzi);
    }

    //查询
    @Override
    public String getcustomerbyname(String customerName) {
        return mapper.getcustomerbyname(customerName);
    }


    //花名册新增员工
    @Override
    public int hmcaddcustomer(Customer customer) {
        return mapper.hmcaddcustomer(customer);
    }


    //花名册编辑前的客户详情查询
    @Override
    public Customer gethmccustdetail(int id) {
        return mapper.gethmccustdetail(id);
    }


    //花名册客户编辑
    @Override
    public int hmcupdatecustomer(Customer customer) {
        return mapper.hmcupdatecustomer(customer);
    }

    //判断手机号是否已经存在
    @Override
    public String queryoldphone(String phone) {
        return mapper.queryoldphone(phone);
    }

    //获取门店下所有员工
    @Override
    public List<User> getuserListbyStoreid(int storeid) {
        return mapper.getuserListbyStoreid(storeid);
    }

    //通过userId查询公司是否存在
    @Override
    public String getconpanycunzaibyuserId(int id) {
        return mapper.getconpanycunzaibyuserId(id) ;
    }


    //修改公司信息
    @Override
    public int updatecustomer(Customer customer) {
        return mapper.updatecustomer(customer);
    }

    //查询该订单下该人员是否存在
    @Override
    public String getcustomerbynameundertuanding(String customerName, String orderSn) {
        return mapper.getcustomerbynameundertuanding( customerName,  orderSn);
    }

    //判断员工工号是否已经存在
    @Override
    public String getstaffNumber(String companyCode, String staffNumber) {
        return mapper.getstaffNumber( companyCode,  staffNumber);
    }


    //通过门店编码查询门店id
    @Override
    public int querystoreIdbycode(String storeCode) {
        return mapper.querystoreIdbycode(storeCode);
    }

    //通过公司编码查询上级的权限编码
    @Override
    public String getupquanxian(String companyOrgcode) {
        return mapper.getupquanxian(companyOrgcode);
    }

    //修改店长权限编码
    @Override
    public void updatedianzhangOrgCode(int userId, String upquanxian) {
       mapper.updatedianzhangOrgCode( userId,  upquanxian);
    }

    //通过token查询公司编码
    @Override
    public String getcompanycodebytoken(String token) {
        return mapper.getcompanycodebytoken(token);
    }

    //通过用户Id查询公司编码
    @Override
    public String getcompanyCodebyuserId(int id) {
        return mapper.getcompanyCodebyuserId(id);
    }

    //通过用户id去公司表查询公司名称
    @Override
    public String getcompanyNamebyuserId(int id) {
        return mapper. getcompanyNamebyuserId(id);
    }

    //通过门店id查询所有地址
    @Override
    public IPage<store> getaddressbystoreId(Page<store> page, String storeId) {
        return mapper.getaddressbystoreId(page,storeId);
    }

    //添加门店地址
    @Override
    public int addstoreaddress(store store) {
        store.setCreateTime(new Date());
        return mapper.addstoreaddress(store);
    }

    //删除门店地址
    @Override
    public int deletestoreaddress(int id) {
        return mapper.deletestoreaddress(id);
    }
    //编辑门店地址
    @Override
    public int updatestoreaddress(store store) {
        return mapper.updatestoreaddress(store);
    }

    //判断该公司下该品牌标是否已存在
    @Override
    public String getoldppb(String ppbname, String companyId) {
        return mapper.getoldppb( ppbname,companyId);
    }

    //查询老的品牌标志id
    @Override
    public int getoldppbid(String ppbname, String companyId) {
        return mapper.getoldppbid( ppbname,  companyId);
    }

    //查询门店名字是否已经存在
    @Override
    public String getoldStorenamecunzai(String storeName) {
        return mapper.getoldStorenamecunzai(storeName);
    }


}
